package org.concepts.algorithm.utils;

public class MathUtils {
  
  /**
   * Returns > 0 is first is greater than second. Returns 0 if the
   * number are the same and < 0 if first number is less than the second.
   * @param first first number. Should not be null.
   * @param second second number. Should not be null.
   * @return 
   */
  public static int compare(Number first, Number second) {
    if (first.doubleValue() == second.doubleValue()) {
      return 0;
    } else if (first.doubleValue() > second.doubleValue()) {
      return 1;
    } else {
      return -1;
    }
  }

  public static void swap(Number[] input, int firstCnt, int secondCnt) {
    Number temp = input[firstCnt];
    input[firstCnt] = input[secondCnt];
    input[secondCnt] = temp;
  }

}
